package com.powernode.springmvc.controller;

import com.powernode.springmvc.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @Author: 曾铖坚
 * @Date: 2024/10/2 11:35
 * @Version: 1.0.0
 */
@Controller
public class UserController {
    @RequestMapping(value = "/user", method = RequestMethod.GET)
    public String getAll() {
        System.out.println("正在查询用户列表...");
        return "ok";
    }

    @RequestMapping(value = "/user/{id}", method = RequestMethod.GET)
    public String getById(@PathVariable("id") String id) {
        System.out.println("正在根据用户id查询用户信息，用户id为：" + id);
        return "ok";
    }

    @RequestMapping(value = "/user", method = RequestMethod.POST)
    public String save(User user) {
        System.out.println("正在保存用户信息...");
        System.out.println(user);
        return "ok";
    }

    @RequestMapping(value = "/user", method = RequestMethod.PUT)
    public String update(User user) {
        System.out.println("正在修改用户信息：" + user);
        return "ok";
    }

    @RequestMapping(value = "/user/{id}", method = RequestMethod.DELETE)
    public String delete(@PathVariable("id") String id) {
        System.out.println("正在删除用户信息：" + id);
        return "ok";
    }
}
